#! /bin/bash

export LANG=en_US.UTF-8


netstat -lnp | grep $1 | grep tcp | awk -F ':::' '{print $2}' | awk -F ' ' '{print $1}' > temp.solr.port
STRNUM=$(cat "temp.solr.port" | wc -l)
for((i=1;i<=$STRNUM;i++));do 
	PORT=$(head -n $i temp.solr.port | tail -n 1)
	CONTENT=$(curl -m 5 http://127.0.0.1:$PORT/solr/admin/cores?wt=json&indexInfo=false&_=1401872715633)
	result=$(echo $CONTENT | grep "defaultCoreName")
	if [[ "$result" != "" ]]
	then
		netstat -lnp | grep $1 | grep tcp |grep $PORT
	fi
done